<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<title>addInput and removeInput</title>
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
 <style type="text/css">
.a{width:205px; height:20px; line-height:20px; border:1px #75a2d1 solid; margin-left:5px; float:left; display:inline;}
.b{width:150px; height:20px; line-height:20px; border:1px #75a2d1 solid; margin-left:5px; float:left; display:inline;}
p.nsem { float:left;margin-left:10px; display:inline; color:#565656; width:890px;}
p.nsem label { line-height:22px; float:left; width:100px; text-align:right;}
span.visp { float:left; line-height:22px; margin-left:10px; display:inline; }
 </style>
<script type="text/javascript">


$(document).ready(function(){
  var spotMax = 5;
  if($('p.nsem').size() >= spotMax) {$(obj).hide();}
  $("input#add").click(function(){     addSpot(this, spotMax);
  });
});
 
function addSpot(obj, sm) {
$('div#spots').append(
 '<p class="nsem">'
+'<label>&nbsp;&nbsp;</label>'
+'<span class="visp"><input name="qqNos" value="553423657" class="a"/></span>'
+'<label>备注名称:</label>'
+'<span class="visp"><input name="qqNotes" value="yanhechao" class="b"/></span>'
+'<input type="button" class="remove" value="remove" />'
+'</p>'
)
  .find("input.remove").click(function(){
    $(this).parent().remove();
    $('input#add').show();
  });
 
  if($('p.nsem').size() >= sm) {$(obj).hide();}
};
</script>
</head>
 
<body>
<p class="nsem">
<label>QQ:</label>
<span class="visp"><input name="qqNos" value="553423657" maxlength="15" class="a"/></span>
<label>备注名称:</label>
<span class="visp"><input name="qqNotes" value="yanhechao" maxlength="20" class="b"/></span>
<input type="button" id="add" value="add" />					
<input type="button" id="send" value="send" />
</p>
<div id="spots">

</div>
<script>
var str="";
var stry="";
  $('#send').click(function(){
  var reg = /^[0-9]*$/
   var x=document.getElementsByName("qqNos");
   var y=document.getElementsByName("qqNotes");
   var tx;
   var ty;
for(var i=0;i<x.length;i++){
    tx = LTrim(x[i].value," ");
	yx = LTrim(y[i].value," ")
  if(!reg.test(tx) || tx=='' || tx.length > 15){
  alert("QQ信息错误!");
  return false;
  }
  if(yx.length > 20 || yx==''){
  alert("备注信息错误");
  return false;
  }
   str=str+"&&"+tx;
   stry=stry+"&&"+yx;
}

alert(LTrim(stry,"&"));  //qqNos
alert(LTrim(str,"&"));   //qqNotes
str="";
stry="";


});

function LTrim(str,cha){ // 去掉字符串（左cha）  
var i;  
for(i=0;i<str.length; i++) {  
if(str.charAt(i)!=cha) break;  
}  
str = str.substring(i,str.length);  
return str;  
}  
function RTrim(str,cha){// 去掉字符串（右cha）  
var i;  
for(i=str.length-1;i>=0;i--){  
if(str.charAt(i)!=cha) break;  
}  
str = str.substring(0,i+1);  
return str;  
}  
function Trim(str,cha){// 去掉字符串（左右cha）  
return LTrim(RTrim(str,cha));  
}  
/**
	j(document).ready(function(){
  var spotMax = 5;
  if(j('p.solensem').size() >= spotMax) {j(obj).hide();}
j("input#addQQ").click(function(){     addSpot(this, spotMax);
});

function addSpot(obj, sm) {
j('div#group').append(
 '<p class="solensem">'
+'<label>&nbsp;&nbsp;</label>'
+'<span class="visp"><input name="qqNos" value="553423657" class="a"/></span>'
+'<label>备注名称:</label>'
+'<span class="visp"><input name="qqNotes" value="yanhechao" class="b"/></span>'
+'<input type="button" class="remove" value="remove" />'
+'</p>'
).find("input.remove").click(function(){
   j(this).parent().remove();
    j('#addQQ').show();
  });
 
  if(j('p.solensem').size() >= sm) {j(obj).hide();}
};



			for(var h = 1; h < vvqqNos.length; h++){
			 j('div.temporary').append(
			 '<p class="nsem" > <label>&nbsp;</label>'
			+'<span class="visp" >'
			+"553245568"
			+'</span>'
			+'<label>&nbsp;</label>'
			+'<span class="visp">'
			+"notexxx"
			+'</span>'
			+'</p>'
			);   
			}   
*/
</script>



</body>
</html>